
package com.jf.cloud.combo.config;

import com.jf.cloud.common.rocketmq.config.RocketMqAdapter;
import com.jf.cloud.common.rocketmq.config.RocketMqConstant;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;

/**
 * @author zz
 * @date 2022/8/31 10:14
 */
@RefreshScope
@Configuration
public class RocketMqConfig {

    @Autowired
    private RocketMqAdapter rocketMqAdapter;

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate comboSkuStatusTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.COMBO_SKU_STATUS_TOPIC);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate comboDeleteOrDisabledTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.COMBO_DELETE_OR_DISABLED);
    }

    @Lazy
    @Bean(destroyMethod = "destroy")
    public RocketMQTemplate comboSpuCountChangeTemplate() {
        return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.COMBO_SPU_COUNT_CHANGE);
    }

}
